Converts "bad" words into ?#*@!

Pass the string to be checked to replace()

====================================================

class swearfilter
{
	static $words = array(
        // TODO: Enter bad words here like so: "bad", 
        );
	
	function replace($haystack)
	{
                // Set the replacements
		$replacements = array("?", "!", "*", "@", "#", "*");
		
                // Loop through each and every word in the $words array
		foreach(swearfilter::$words as $needle)
		{
			$replace = '';
			// Create our replacement string by string length
			for($i=0; $i<strlen($needle); $i++)
			{
				$radnum = rand(0, 5);
				$replace .= $replacements[$radnum];
			}
			
			// Search for the current word and replace
			$haystack = str_ireplace($needle, $replace, $haystack);
		}
                // Return the "clean" text
		return $haystack;
	}
}